package pl.koziczak.knowledgeintegration.algorithm;

import org.w3c.dom.Document;

import pl.koziczak.knowledgeintegration.exception.KnowledgeIntegrationException;
import pl.koziczak.knowledgeintegration.model.Class;
import pl.koziczak.knowledgeintegration.model.builder.DocumentBuilder;
import pl.koziczak.knowledgeintegration.model.builder.ModelBuilder;

public class KnowledgeIntegratorImpl implements KnowledgeIntegrator {

	private ModelBuilder modelBuilder;
	private DocumentBuilder documentBuilder;
	public KnowledgeIntegratorImpl() {
		modelBuilder = ModelBuilder.getInstance();
		documentBuilder = DocumentBuilder.getInstance();
	}
	@Override
	public Document integration(Document xmlFirst, Document xmlSecond)
			throws KnowledgeIntegrationException {
		
		Class firstClass = modelBuilder.build(xmlFirst);
		Class secondClass = modelBuilder.build(xmlSecond);
		Class resultClass = integration(firstClass, secondClass);
		System.out.println(resultClass.toString());
		Document xmlResult = documentBuilder.build(resultClass);
		
		return xmlResult;
	}

	private Class integration(Class first, Class second) {
		return first;
	}
}
